﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading;
using System.Windows.Forms;
using Gma.UserActivityMonitor;
using QAQ;

namespace aaaaaa
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private Stopwatch sw = null;
        private long lastMS;

        private void addlog(string s)
        {
            if (null == sw)
            {
                sw = new Stopwatch();
                sw.Start();
                lastMS = 0;
            }
            else
            {
                var wait = sw.ElapsedMilliseconds - lastMS;
                lastMS = sw.ElapsedMilliseconds;
                this.listBox1.Items.Insert(0, string.Format("wait {0}", wait));
            }
            this.listBox1.Items.Insert(0, s);
            while (this.listBox1.Items.Count > 100)
            {
                this.listBox1.Items.RemoveAt(this.listBox1.Items.Count - 1);
            }
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            HookManager.KeyDown += (s, ev) => addlog(String.Format("KeyDown {0}", ev.KeyData));
            HookManager.KeyUp += (s, ev) => addlog(String.Format("KeyUp {0}", ev.KeyData));

            HookManager.MouseUp += (s, ev) => addlog(String.Format("MouseUp {0} {1}", ev.Location, ev.Button));
            HookManager.MouseDown += (s, ev) => addlog(String.Format("MouseDown {0} {1}", ev.Location, ev.Button));
            HookManager.MouseMove += (s, ev) => addlog(String.Format("MouseMove {0}", ev.Location));
            HookManager.MouseWheel += (s, ev) => addlog(String.Format("MouseWheel {0} {1}",ev.Location,ev.Delta));
            

            

            HookManager.MouseDown += (s, ev) =>
            {
                if (ev.Button == MouseButtons.Right)
                {
                    this.listBox1.Items.Clear();
                }
            };
        }
    }
}
